import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
// import viteCompression from 'vite-plugin-compression';
import { viteMockServe } from 'vite-plugin-mock'
// import legacy from '@vitejs/plugin-legacy'
import path from 'path';

// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) =>({ 
  base:'/',
  css: {
    preprocessorOptions: {
    }
  },
  optimizeDeps: {
    // include: [""], 强制构建
  },
  plugins: [
    vue(),
    vueJsx(),
    viteMockServe({
      // default
      mockPath: './src/mock/',
      supportTs:true,
      // localEnabled: command === 'serve',
      localEnabled: true, 
    })
  ],
  resolve: {
    alias: [
      { find: "@", replacement: path.resolve(__dirname, 'src') }, 
    ],
  },
  build: {
    minify: true,
    sourcemap: true
  },
  server: {
    port: 4000,
    proxy: { 
      '/channel': {
        target: '',
        changeOrigin: true,
      } 
    }
  }
})); 